﻿package bdz.projects.lavender.doi.ui
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.utils.*;
	import org.papervision3d.core.math.Plane3D;
	import org.papervision3d.view.Viewport3D;
	
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.materials.*;
	import org.papervision3d.objects.primitives.Plane;
	
	/**
	 * ...
	 * @author ...
	 */
	public class DOIPlanesHolder extends DisplayObject3D 
	{
		private var _movieclip:MovieClip;
		private var _viewport:Viewport3D;
		private var _plane:Plane;
		public function DOIPlanesHolder(mc:MovieClip, vport:Viewport3D) {
			_movieclip = mc;
			_viewport = vport;
			createPlane();
		}
		private function createPlane():void {
			var mat:MovieMaterial = new MovieMaterial(_movieclip, true, true, true);
			mat.name = new Date().getTime().toString();
			mat.smooth = true;
			mat.interactive = true;
			mat.doubleSided = true;
			
			mat.allowAutoResize = true;
			
			_plane = new Plane(mat, 680, 420, 6, 6);
			addChild(_plane);
			
			//setTimeout(applyButtonActions, 100);
		}
		private function applyButtonActions():void {
			_movieclip.testb.addEventListener(MouseEvent.ROLL_OVER, activeButtonHand);
			_movieclip.testb.addEventListener(MouseEvent.ROLL_OUT, activeButtonHand);
		}
		private function activeButtonHand(evt:MouseEvent):void {
			_viewport.buttonMode = evt.type == MouseEvent.ROLL_OVER;
		}
		public function get plane():Plane {
			return _plane;
		}
		public function get mc():MovieClip {
			return _movieclip;
		}
	}
	
}